package com.bci.pwtz.task;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.bci.pwtz.task.thread.BaseThread;

public class TaskManager
{    
    private final static Logger _logger = Logger.getLogger(TaskManager.class);
    
    public static List<Thread> threads = new ArrayList<Thread>();
    
    public static void stopAll()
    {
        for(Thread t : threads)
        {
            try
            {
                t.interrupt();
            }
            catch(Exception e)
            {}
        }
    }
    
    public static void start(BaseThread baseThread)
    {        
        _logger.info(baseThread.threadName+"开始启动,interval="+baseThread.interval+"s");
        Thread t = new Thread(baseThread);
        t.setDaemon(true);
        t.start();
        threads.add(t);
    }
}
